How to make a Phoenix live CD from a Debian installation
=Introduction= The Phoenix live CD, apart from being a medium which you can boot into and start running Phoenix, contains a Debian repository of the packages required for running Phoenix. It also contains the software required for running Phoenix from Windows (mainly winPython). So these folders will be assumed to be on a separate CD (call it the "repo CD") at the time of preparing the base system. This repo CD also contains the documents for Phoenix, in a directory called "docs", and the GNU General Public License. = Installing required packages on the source system= You need a standard (minimal) Debian installation (no Gnome/KDE. We will be using ICEWM) with the following packages installed. apt-get install xorg icewm rox-filer joe python-serial python-tk python-imaging python-imaging-tk \ python-numpy grace python-numeric python-scipy python-matplotlib gcc-avr avr-libc \ uisp rasmol mkisofs squashfs-tools hal ivman pmount nedit iceweasel rsync qiv xpdf Some of these packages were downloaded from the online official and backports repositories of Debian. If you need help in configuring APT to use these repositories, refer to this page for instructions. Note: If you wish to make a custom live CD of your own, install whichever packages you want. We need the packages squashfs-tools, mkisofs, live-initramfs, squashfs-modules and unionfs-modules to build the live CD from the installation. The packages squashfs-modules and unionfs-modules are kernel dependent. If these packages are available for the kernel installed on your system, fine! Just install these four packages by running apt-get install squashfs-tools mkisofs live-initramfs squashfs-modules-$(uname -r) \ unionfs-modules-$(uname -r) Note: If these modules are not available for your kernel, which is what happened in our case, search on packages.debian.org and find out the kernels for which they are available, and install one of them. After installing the kernel, reboot and choose the newly installed kernel from the boot menu. Now remove the old kernel. Copy the Phoenix python module phm.py to /usr/lib/python2.4/site-packages/ Copy "docs" from the repo CD, to / By default, the live scripts will create a user named "user" and login automatically as "user" into the shell. Since we need to login as "root", we make a small change in the file /sbin/live-login . It checks for the the user details in a file /etc/live.conf . So to skip checking, make the if condition FALSE. You can also just replace the file with the contents given below: #!/bin/sh set -e USERNAME="root" exec /bin/login -f "${USERNAME}" =Making the live CD= Now we are ready to make the live CD, using the following script. This method was made possible solely because of an excellent how-to on converting a Debian/Ubuntu installation into a live CD, on the Ubuntu forumshttp://ubuntuforums.org/showthread.php?t=688872. All the main steps followed in the script have been simply copied from the how-to, and customized to meet our needs. This script assumes the repo CD to be mounted at /media/cdrom (if there's any change make the correction in the script), and also the file "grubmenu" to be in the directory /docs/live_scripts . Note: Download this tarball and extract it to /docs. Then cd to /docs/live_scripts/ and run "./make_livecd.sh", whose code is given below. #!/bin/sh #Set some variables export DIR=/tmp/work/rootfs export WORK=/tmp/work export CD=/tmp/cd export FORMAT=squashfs export FS_DIR=live #Unmount all disk drives before copying files umount -a #Create the CD and the WORK directory structure mkdir -p ${CD}/{${FS_DIR},boot/grub} ${WORK}/rootfs #Copy directories to be included on the CD. Here we assume that these directories are present on the #repo CD, and that it is mounted at /media/cdrom. This step can be skipped if you need only a live CD. cp -r /media/cdrom/phoenix $CD cp -r /media/cdrom/debs $CD cp -r /media/cdrom/winPython $CD cp /media/cdrom/COPYING $CD #Copy the installed system to the work area rsync -av --one-file-system --exclude=/proc/* --exclude=/dev/*\ --exclude=/sys/* --exclude=/tmp/* --exclude=/home/*\ --exclude=/lost+found / ${WORK}/rootfs #Mounting proc and dev to new system mount -o bind /dev/ ${WORK}/rootfs/dev mount -t proc proc ${WORK}/rootfs/proc # ???? chroot $DIR (set variable LANG to nothing) how ? CD works even without this step #Modifications to be made in the newly copied filesystem, mainly cleaning up. chroot $DIR depmod -a $(uname -r) chroot $DIR update-initramfs -u -k $(uname -r) chroot $DIR apt-get clean chroot $DIR rm -r /tmp/* /root/* 2>/dev/null chroot $DIR rm /boot/*.bak 2>/dev/null #Copy ICEWM configuration cp /docs/live_scripts/desktop_settings/menu $DIR/etc/X11/icewm/ cp /docs/live_scripts/desktop_settings/toolbar $DIR/etc/X11/icewm/ cp /docs/live_scripts/desktop_settings/startup $DIR/etc/X11/icewm/ rm $DIR/root/.mozilla -rf rm $DIR/media/* -rf rm -f $DIR/etc/hosts $DIR/etc/hostname $DIR/etc/resolv.conf \ $DIR/etc/timezone $DIR/etc/fstab $DIR/etc/mtab $DIR/etc/shadow \ $DIR/etc/shadow- $DIR/etc/gshadow $DIR/etc/gshadow- \ $DIR/etc/gdm/gdm-cdd.conf $DIR/etc/gdm/gdm.conf-custom \ $DIR/etc/X11/xorg.conf $DIR/boot/grub/menu.lst $DIR/boot/grub/device.map #Removing non system users for i in `chroot $DIR cat /etc/passwd | chroot $DIR awk -F":" '{print $1}'` do uid=`chroot $DIR cat /etc/passwd | chroot $DIR grep "^${i}:" | \ chroot $DIR awk -F":" '{print $3}'` [ "$uid" -gt "999" -a "$uid" -ne "65534" ] && chroot $DIR \ userdel --force ${i} 2>$DIR/dev/null done find $DIR/var/run $DIR/var/log $DIR/var/mail $DIR/var/spool $DIR/var/lock \ $DIR/var/backups $DIR/var/tmp -type f -exec rm {} \; for i in dpkg.log lastlog mail.log syslog auth.log daemon.log faillog lpr.log \ mail.warn user.log boot debug mail.err messages wtmp bootstrap.log \ dmesg kern.log mail.info do chroot $DIR touch /var/log/${i} done #Disabling root password ex $DIR/etc/passwd << EOF :g/root:x/s//root:/g :wq EOF #Preparing the /boot directory of the CD cp -vp ${WORK}/rootfs/boot/vmlinuz-$(uname -r) ${CD}/boot/vmlinuz cp -vp ${WORK}/rootfs/boot/initrd.img-$(uname -r) ${CD}/boot/initrd.gz #Unmount bind mounted dirs umount ${WORK}/rootfs/proc umount ${WORK}/rootfs/sys umount ${WORK}/rootfs/dev #Make the compressed filesystem image mksquashfs ${WORK}/rootfs ${CD}/${FS_DIR}/filesystem.${FORMAT} find /boot /usr/lib/grub/ -iname 'stage2_eltorito' -exec cp -v {} ${CD}/boot/grub \; #Copy the boot menu cp /docs/live_scripts/grubmenu ${CD}/boot/grub/menu.lst #Find MD5 sum cd $CD && find . -type f -print0 | xargs -0 sudo md5sum | sudo tee ${CD}/md5sum.txt #Make the ISO image of the live CD. The image will be found in the home directory. mkisofs -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \ -V "Custom Live CD" -cache-inodes -r -J -l -o ~/live-cd.iso $CD =Testing the live CD= You can test the ISO image just made, without wasting a CD-ROM, by following these steps: *Mount the ISO image using loop back by typing the following command at the terminal. mount -o loop *Copy the contents of the ISO into an empty ext2/3 partition. *Modify your boot menu. Append the lines found in the file "grubmenu", and specify the partition to boot from. It should look something like- # By default, boot the first entry. default 0 # Boot automatically after 30 secs. timeout 30 color cyan/blue white/blue title Start Linux in Text Mode root (hd0, 2) kernel /boot/vmlinuz BOOT=live boot=live nopersistent live-getty textonly rw quiet noapic initrd /boot/initrd.gz where (hd0,x) specifies the partition number 'x' on the hard disk number 0. *Reboot and choose this option next time, to boot into the live operating system.